<template>
	<view class="iden_select">
		<!-- #ifdef APP-PLUS -->
		<top-set></top-set>
		<tab-top title="选择角色"></tab-top>
		<!-- #endif -->
		<view class="box">
			<!-- 酒店 -->
			<view class="iden_img h-img" @tap="changeType('2')">
				<image src="/static/identity/hotel-img.png" mode=""></image>
			</view>
			<view class="iden_checkbox" @tap="changeType('2')">
				<view class="checkbox_btn">
					<image :src="idenType=='2'?'/static/identity/check_active.png':'/static/identity/check.png'" mode=""></image>

				</view>
				<view class="checkbox_text">我是酒店方</view>
			</view>
			<!-- 保洁 -->
			<view class="iden_img c-img" @tap="changeType('1')">
				<image src="/static/identity/cleaner-img.png" mode=""></image>
			</view>
			<view class="iden_checkbox" @tap="changeType('1')">
				<view class="checkbox_btn">
					<image :src="idenType=='1'?'/static/identity/check_active.png':'/static/identity/check.png'" mode=""></image>
				</view>
				<view class="checkbox_text">我是服务员</view>
			</view>
			<view class="uni-padding-wrap uni-common-mt">
				<button type="primary" @tap="conIden()">确定</button>
			</view>
		</view>
	</view>
</template>

<script>
	let uid;
	export default {

		data() {
			return {
				idenType: '2', // 1(服务) 2(酒店)
			}
		},
		onLoad(e){
			console.log(e);
			uid = e.uid;
			
		},
		methods: {
			changeType(str) {
				this.idenType = str;
			},
			conIden() {
				console.log(uid);
				this.req({
						url:'user/editAccountType',
						data:{
							id:uid,
							type:this.idenType
						}
					},
					(res) => {
						if(res.data.status == 1){
							this.storageToStore();
						}
					},
					(res) => {
						
					}
				);
				
			},
			storageToStore(){
				/**
				 * 存储端口类型信息到本地 并修改状态信息
				 */
				this.termTypeUpdate(this.idenType);
				uni.navigateBack({
					delta: 10
				});
			}
		},
		mounted() {

		},
		computed: {

		}
	}
</script>

<style lang="scss">
	.iden_select {
		.box {
			margin: 0 auto;
			width: 540upx;

			.iden_img {
				margin: 0 auto;
				width: 201upx;
				height: 226upx;
				font-size: 0;

				image {
					display: block;
					width: 100%;
					height: 100%;
				}
			}

			.h-img {
				margin-top: 137upx;

			}

			.c-img {
				margin-top: 100upx;
			}

			.iden_checkbox {
				margin: 0 auto;
				margin-top: 29upx;
				width: 201upx;
				height: 32upx;
				font-size: 28upx;

				.checkbox_text {
					margin-left: 20upx;
					float: left;
				}

				.checkbox_btn {

					float: left;
					width: 32upx;
					height: 32upx;

					image {
						width: 100%;
						height: 100%;

					}
				}
			}

			.uni-common-mt {
				position: fixed;
				width: 540upx;
				left: 0;
				right: 0;
				margin: 0 auto;
				bottom: 45upx;

				button {
					background: #3595F9 !important;
				}
			}
		}
	}
</style>
